From: Jan Beulich Date: Mon, 3 Sep 2012 06:17:50 +0000 (+0200) Subject: x86: comment opaque expression in __page_to_virt() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~7998 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=aa1c1f4c57720d3f8426aab89cf8217dd687a651;p=xen.git x86: comment opaque expression in __page_to_virt() mm.h's __page_to_virt() has a rather opaque expression. Comment it. Reported-By: Ian Campbell Suggested-by: Ian Jackson Signed-off-by: Jan Beulich Acked-by: Keir Fraser --- diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 4cba2765fb..2ed53d9416 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -323,6 +323,12 @@ static inline struct page_info *__virt_to_page(const void *v) static inline void *__page_to_virt(const struct page_info *pg) { ASSERT((unsigned long)pg - FRAMETABLE_VIRT_START < FRAMETABLE_VIRT_END); + /* + * (sizeof(*pg) & -sizeof(*pg)) selects the LS bit of sizeof(*pg). The + * division and re-multiplication avoids one shift when sizeof(*pg) is a + * power of two (otherwise there would be a right shift followed by a + * left shift, which the compiler can't know it can fold into one). + */ return (void *)(DIRECTMAP_VIRT_START + ((unsigned long)pg - FRAMETABLE_VIRT_START) / (sizeof(*pg) / (sizeof(*pg) & -sizeof(*pg))) *